#ifndef DESKNOTES_H
#define DESKNOTES_H

class DeskNotes;

#include "common.h"
#include "Settings.h"
#include "CassiopeiaMain.h"

#define DeskNotes_MenuFirstId				0x0001
#define MenuEdit_Save						DeskNotes_MenuFirstId
#define MenuSystem_ShrinkRestore			DeskNotes_MenuFirstId + 1
#define MenuSystem_TopMost					DeskNotes_MenuFirstId + 2
#define MenuSystem_TransparentOnLeave		DeskNotes_MenuFirstId + 3
#define MenuSystem_Separator1				DeskNotes_MenuFirstId + 4
#define MenuEdit_Separator1					DeskNotes_MenuFirstId + 5
#define MenuEdit_ResetZoom					DeskNotes_MenuFirstId + 6

#define MenuSystem_Separator2				DeskNotes_MenuFirstId + 7
#define MenuSystem_Close					DeskNotes_MenuFirstId + 8


class DeskNotes : public CassiopeiaComponent, public Window
{
public:
	DeskNotes(bool registerHotkey = true, tstring title = TEXT("Notes"));
	~DeskNotes();
	void Create(HINSTANCE hInstance);
	CCState Activate();
	CCState Deactivate();

private:
	bool SaveDeskNote();
	bool LoadDeskNote();
	tstring GetDeskNoteFileName();
	tstring GetDeskNoteArchiveFileName();
	bool FillRichEditFromFile(HWND hWnd, LPCTSTR pszFile);
	bool SaveRichEditToFile(HWND hWnd, LPCTSTR pszFile);
	void Shrink(bool value);
	void LoadRichEditConfiguration();

	HWND editHWnd;
	HMENU systemMenu;
	HMENU editMenu;

	int width;
	int height;
	int minWidth;
	int minHeight;
	int dwmMarginSize;
	int roundCornerValue;
	int restoredHeight;

	bool topMost;
	bool transparentOnLeave;
	bool shrunken;
	bool registerHotkey;

	tstring title;

	static BOOL dwmEnabled;

	static UINT WM_CLOSESUBDESKNOTES;
	static UINT WM_ACTIVATESUBDESKNOTES;
	static UINT WM_DEACTIVATESUBDESKNOTES;

	static DWORD CALLBACK EditStreamCallbackRead(DWORD_PTR dwCookie, LPBYTE lpBuff,LONG cb, PLONG pcb);
	static DWORD CALLBACK EditStreamCallbackWrite(DWORD_PTR dwCookie, LPBYTE lpBuff,LONG cb, PLONG pcb);
	static LRESULT CALLBACK WndProc(LPVOID sender, HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
	static VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT_PTR	idEvent,DWORD dwTime);
	
	static BOOL CALLBACK EnumWindowsProc_Activate(HWND hWnd, LPARAM lParam);
	static BOOL CALLBACK EnumWindowsProc_Deactivate(HWND hWnd, LPARAM lParam);
	static BOOL CALLBACK EnumWindowsProc_Close(HWND hWnd, LPARAM lParam);
};

#endif